unsafe_unwrap 0.1.0

Unsafely unwrap Result and Option types without checking.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 3 items with examples
  • Size
  • Source code size: 18.90 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 166.40 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • nvzqz/unsafe-unwrap-rs
    5 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nvzqz

unsafe_unwrap

A Rust library that enables unchecked unwrapping on Option and Result types.

Usage

The unsafe_unwrap() method can be used anywhere unwrap() is used. It behaves similar to unwrap() in unoptimized builds and will remove checks in optimized builds.

extern crate unsafe_unwrap;
use unsafe_unwrap::UnsafeUnwrap;

let x = Some(42);
let y = unsafe { x.unsafe_unwrap() };

Benchmark

bench_normal_unwrap_1000 bench_unsafe_unwrap_1000
929 ns/iter (+/- 176) 302 ns/iter (+/- 28)

License

This project is released under either:

at your choosing.